﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Management;
using System.Text;

namespace WMI.NET.CIM
{
    /// <summary>
    /// The CIM_Controller class is a parent class for grouping miscellaneous control-related devices. Examples of controllers are SCSI controllers, USB controllers, and serial controllers. The CIM_Controller class is an abstraction for devices with a single protocol stack, which exist primarily for communication to, and control or reset of, downstream (CIM_ControlledBy) devices.
    /// </summary>
    public class CIM_Controller : CIM_LogicalDevice
    {

        private Nullable<UInt32> _MaxNumberControlled;
        private Nullable<UInt16> _ProtocolSupported;
        private Nullable<DateTimeOffset> _TimeOfLastReset;

        /// <summary>
        /// Maximum number of directly addressable entities supported by this controller. A value of 0 should be used if the number is unknown or unlimited.
        /// </summary>
        public Nullable<UInt32> MaxNumberControlled { get { return _MaxNumberControlled; } }

        /// <summary>
        /// Protocol used by the controller to access 'controlled' devices.
        /// </summary>
        public Nullable<UInt16> ProtocolSupported { get { return _ProtocolSupported; } } //TODO enum

        /// <summary>
        /// Date and time the controller was last reset (powered down or reinitialized).
        /// </summary>
        public Nullable<DateTimeOffset> TimeOfLastReset { get { return _TimeOfLastReset; } }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="mbo"></param>
        public CIM_Controller(ManagementBaseObject mbo)
            : base(mbo)
        {
            _MaxNumberControlled = mbo.GetUIntValue("MaxNumberControlled");
            _ProtocolSupported = mbo.GetUshortValue("ProtocolSupported");
            _TimeOfLastReset = mbo.GetDateTimeOffsetValue("TimeOfLastReset", Consts.DateTimeFormat);
        }

    }
}
